package com.weizhu.swufer.core.client;

import com.weizhu.swufer.autoconfiguration.SwuferProperties;
import com.weizhu.swufer.constant.SwuferConstant;

public class ReferenceConfig{

    private Class<?> tClass;

    private String referServiceName;

    //milliseconds 为负值时
    private long maxWaitTime = -1L;

    private Class<?> clusterClass;

    private Class<?> loadBalancerClass;

    private String targetAddress;

    private boolean async = false;

    private int tryTimes = SwuferConstant.DEFAULT_TRY_TIMES;

    public String getTargetAddress() {
        return targetAddress;
    }

    public void setTargetAddress(String targetAddress) {
        this.targetAddress = targetAddress;
    }

    public ReferenceConfig(){

    }

    public ReferenceConfig(SwuferProperties swuferProperties){

    }

    public static ReferenceConfig ref(Class referClass){
        ReferenceConfig config = new ReferenceConfig();
        config.tClass = referClass;
        config.referServiceName = referClass.getName();
        return config;
    }

    public int getTryTimes() {
        return tryTimes;
    }

    public void setTryTimes(int tryTimes) {
        this.tryTimes = tryTimes;
    }

    public Class<?> gettClass() {
        return tClass;
    }

    public void settClass(Class tClass) {
        this.tClass = tClass;
    }

    public String getReferServiceName() {
        return referServiceName;
    }

    public void setReferServiceName(String referServiceName) {
        this.referServiceName = referServiceName;
    }

    public Class<?> getClusterClass() {
        return clusterClass;
    }

    public void setClusterClass(Class<?> clusterClass) {
        this.clusterClass = clusterClass;
    }

    public Class<?> getLoadBalancerClass() {
        return loadBalancerClass;
    }

    public void setLoadBalancerClass(Class<?> loadBalancerClass) {
        this.loadBalancerClass = loadBalancerClass;
    }

    public long getMaxWaitTime() {
        return maxWaitTime;
    }

    public void setMaxWaitTime(long maxWaitTime) {
        this.maxWaitTime = maxWaitTime;
    }

    public void setAsync(boolean async) {
        this.async = async;
    }

    public boolean isAsync() {
        return async;
    }
}
